-- ==== BEGIN LICENSE BLOCK ====
-- storyboard-addon - Copyright (C) Arnaud Charnoz, 2006-2010.
-- Distributed under the terms of the GNU Lesser General Public License (LGPL) as
-- published by the Free Software Foundation.
-- ===== END LICENSE BLOCK ====
 
if sb == nil
then
    sb = {};
    if sb.ui == nil
    then
       sb.ui = {}; 
    end
end

sb.ui.MenuGameController = {};
sb.ui.MenuGameController.storyline = nil;

-------------------------------------------------------------------------------

function sb.ui.MenuGameController:init()

    sb_ui_MenuGameFrame_Title:SetText("SB Game Menu");
    
end

-------------------------------------------------------------------------------

function sb.ui.MenuGameController:ObserveZone()
    
    local msg = "Vous observez les lieux mais vous ne voyez rien de particulier.";
    local key = StoryBoard.currentStoryline.locationDB:hasLocationWherePlayerIs();  
    
    if ( key ~= nil )
    then
        msg = StoryBoard.currentStoryline.locationDB.db[ key ]:getInfo();
    end
    
    SBMessageManager:showInformation( msg );
       
end

-------------------------------------------------------------------------------

function sb.ui.MenuGameController:showStorylineAbstract()

    local story = StoryBoard.currentStoryline;

   SbIntroHomeTitre:SetText( story.title ); 
   SbIntroHomeAuteur:SetText( "Ecrit par : " .. story.authorA );
   
   SbIntroText:SetText( "Autre auteur :\n" .. story.authorB );
   SbIntroText:SetText( SbIntroText:GetText() .. "\nAutre auteur : :\n" .. story.authorC );
   SbIntroText:SetText( SbIntroText:GetText() .. "\n\nVersion du scénario : " .. story.textVersion );
   SbIntroText:SetText( SbIntroText:GetText() .. "\n\nPrérequis Faction : " .. story.factionRequirement );
   SbIntroText:SetText( SbIntroText:GetText() .. "\nPrérequis Niveau : " .. story.levelRequirement );
   SbIntroText:SetText( SbIntroText:GetText() .. "\nAutres prérequis : " .. story.otherRequirements );
   SbIntroText:SetText( SbIntroText:GetText() .. "\n\nRésumé de l'histoire :\n" .. story.abstract );
   SbIntroText:SetText( SbIntroText:GetText() .. "\n\nDébut de l'histoire :\n" .. story.starter );

   SbIntro:Show();

end

-------------------------------------------------------------------------------

function sb.ui.MenuGameController:reloadTutorialStoryline()

    if ( StoryBoard.db.profile.tutorialStoryline ~= nil )
    then
        StoryBoard.currentStoryline:importFromString( StoryBoard.db.profile.tutorialStoryline );
    end
    
end

-------------------------------------------------------------------------------

function sb.ui.MenuGameController:onStorylineDBManagerButton()

    if sb.ui.StorylineDBManagerController:IsVisible() then
        sb.ui.StorylineDBManagerController:Hide();
    else
        sb.ui.StorylineDBManagerController:Show();
    end
end
